﻿using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BirthdayRemainder
{
    public class ListViewCompare : IComparer
    {
        public int SortColumn { get; set; }
        public ListViewCompare()
        {
            SortColumn = 0;
        }
        public ListViewCompare(int column)
        {
            SortColumn = column;
        }
        public int Compare(object x, object y)
        {
            int nX, nY;
            nX = Convert.ToInt32(((ListViewItem)x).SubItems[SortColumn].Text);
            nY = Convert.ToInt32(((ListViewItem)y).SubItems[SortColumn].Text);
            if (nX > nY)
            {
                return 1;
            }
            else if (nX == nY)
            {
                return 0;
            }
            else
            {
                return -1;
            }
            //return string.Compare(((ListViewItem)x).SubItems[SortColumn].Text, ((ListViewItem)y).SubItems[SortColumn].Text);
        }
    }
}
